package logic

import (
	"context"
	"house123/B/src/model/mysql"

	"house123/B/src/house"
	"house123/B/src/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUserListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserListLogic {
	return &UserListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UserListLogic) UserList(in *house.UserListRequest) (*house.UserListResponse, error) {
	// todo: add your logic here and delete this line
	var user = []mysql.User{}
	mysql.DB.Find(&user)
	users := []*house.UserList{}
	for _, i2 := range user {
		list := house.UserList{
			Username: i2.Username,
			Password: i2.Password,
			Status:   i2.Start,
		}
		users = append(users, &list)
	}
	return &house.UserListResponse{List: users}, nil
}
